<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/weui.css" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/weui2.css" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/weui3.css" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/jquery-weui.min.css" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/style.css" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/icon.css" />
    <link rel="stylesheet" type="text/css" href="{$_G['addon_url']}/Public/css/adminXQ.css"/>
    <title></title>
</head>
<style>
            @media screen and (max-width: 400px) {
                .roo img {
                    width:87px;
                    height:87px;
                }
            }
        </style>

{:hook('jssdk',false)}
<script>
    wx.ready(function () {
        wx.onMenuShareTimeline({
            title: '{$data['describe']}', // 分享标题
            link: '{:get_current_url()}', // 分享链接
            imgUrl: "<?php echo 'http://'.$_SERVER['HTTP_HOST']; ?>/__ROOT__/{$data['imgs'][0]}"
        });

        wx.onMenuShareAppMessage({
            title: '{$info['nickname']}的店铺', // 分享标题
            desc: '<if condition="$data['info_type']==1">求购信息<else/>货品信息</if>:{$data['describe']}', // 分享链接
            link: '{:get_current_url()}', // 分享链接
            imgUrl: "<?php echo 'http://'.$_SERVER['HTTP_HOST']; ?>/__ROOT__/{$data['imgs'][0]}", // 分享图标
            type: '', // 分享类型,music、video或link，不填默认为link
            dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
            success: function () {
                // 用户确认分享后执行的回调函数
            },
            cancel: function () {
                // 用户取消分享后执行的回调函数
            }
        });

    })
    function needAuth(x){
        $.ajax({
            url:"{:create_mobile_url('isAuth')}",
            type:"get",
            dataType:"json",
            data:{},
            success:function(data){
                console.log(data);
                if (data.status == 1) {
                    window.location.href = "tel:"+$(x).attr('tel');
                } else {
                    $.toast("请先关注公众号", "forbidden");
                    setTimeout(function(){
                        location.href = "{:create_mobile_url('code')}";
                    },1500);
                    return false;
                }
            },
            error:function(){
                $.toast("错误", "forbidden");
            }
        });
        return true;
    }
</script>
<body>
<div class="weui-header bg-orange">
    <div class="weui-header-left">
        <a class="icon icon-109 f-white" href="javascript:history.go(-1)"></a>
    </div>
    <h1 class="weui-header-title">详情</h1>
</div>
<div class="weui_cells moments">
    <!-- 普通的post -->
    <div class="weui_cell moments__post weui-border-b">
        <div class="weui_cell_hd">
            <img class="circle" src="{$info['headimgurl']}">
        </div>
        <div class="weui_cell_bd">
            <!-- 人名链接 -->
            <a class="title" href="javascript:;">
                <span class="f-blue">{$info['nickname']}</span>
            </a>
            <a tel="{$data['mobile']}" href="javascript:void(0)" class="phone" onclick="needAuth(this)"> <span class="icon icon-104"></span> </a>
            <!-- post内容 -->
            <p id="paragraph" class="paragraph">
                {$data['describe']}
            </p>
            <!-- 相册 -->
            <div class="thumbnails">

               <volist name="data['imgs']" id="val">
                   <div class="roo">
                       <img class="img-max" src="{$val}">
                   </div>
               </volist>

            </div>
            <!-- 资料条 -->
            <div class="toolbar">
                <p class="timestamp">{:date('m-d H:i',$data['create_time'])}</p>
                <div>
                    <div id="actionMenu" class="actionMenu slideIn">
                        <p class="actionBtn" id="btnLike"><i class="icon icon-96"></i></p>
                        <p class="actionBtn" id="btnComment"><i class="icon icon-3"></i></p>
                    </div>
                </div>
                <span id="actionToggle" class="actionToggle">..</span>
            </div>


        </div>
        <!-- 结束 post -->
        <div class="liketext">
            <!-- 赞／评论区 -->
            <volist name="comments" id="val">
                <if condition="$val['id']">
                    <ul class="weui-comment">
                        <li class="weui-comment-item" id="{$val['id']}">
                            <div class="userinfo"> <strong class="nickname" style="padding-left: 35px;">{$val['username']}</strong> <img class="avatar" src="{$val['headimgurl']}"> </div>
                            <div class="weui-comment-msg" style="padding-left: 35px;"> <span class="stat"> {$val['content']} </span>
                                <if condition="$val['c']">
                                    <volist name="val['c']" id="c">
                                        <div class="replay" style="margin-top: 6px" id="{$c['id']}">
                                            <span class="nickname" style="font-size: 15px">{$c['username']}</span>&nbsp;回复 {$c['rele']}:

                                            <span class="weui-comment-msg">{$c['content']}</span>
                                        </div>
                                    </volist>
                                </if>
                            </div>
                        </li>
                    </ul>
                </if>
            </volist>
        </div>
        <div class="weui_cells weui_cells_form" style="display: none;" id="pinglun">
            <div class="weui_cell weui_vcode">
                <div class="weui_cell_bd weui_cell_primary">
                    <input class="weui_input" type="text" placeholder="评论" pid="0">
                </div>
                <div class="weui_cell_ft">
                    <a href="javascript:;" class="weui-vcode-btn bg-orange fasong">发送</a>
                </div>
            </div>
        </div>
    </div>
</div>
<a href="javascript:;" class="weui_btn weui_btn_mini weui_btn_default">{$num}条记录</a>
</body>
<script src="{$_G['addon_url']}/Public/js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{$_G['addon_url']}/Public/js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="{$_G['addon_url']}/Public/js/swiper.js" type="text/javascript" charset="utf-8"></script>
<script src="{$_G['addon_url']}/Public/js/showimg.js" type="text/javascript" charset="utf-8"></script>
<script src="{$_G['addon_url']}/Public/js/zepto.min.js" type="text/javascript" charset="utf-8"></script>
<!--图片放大-->
<script type="text/javascript">
    //		评论输入框的行为
    $(function() {
        $('.moments').on('click', '.actionToggle', function(e) {
            $('input.weui_input').attr('placeholder', '评论');
            $('#pinglun').toggle(1);
            $('#pinglun').find('input.weui_input').focus();
            e.stopPropagation();
        });
        $('.moments').on('click', '.weui-comment-item', function(e) {
            var id = $(this).attr('id');
            var usename = $(this).find('.nickname').html();
            var pinglun = $(this).parents('.liketext').siblings('.weui_cells_form');
            pinglun.find('input.weui_input').attr('placeholder', '回复' + usename);
            pinglun.find('input.weui_input').attr('pid',id);
            pinglun.show(1);
            pinglun.find('input.weui_input').focus();
            e.stopPropagation();
        });
        $('.moments').on('click', '.weui-comment-msg .replay', function(e) {
            var usename = $(this).find('.nickname').html();
            var id = $(this).attr('id');
            var xiaoxi = $(this).parents('.liketext').siblings('.weui_cells_form');
            xiaoxi.find('input.weui_input').attr('placeholder', '回复' + usename);
            xiaoxi.find('input.weui_input').attr('pid',id);
            xiaoxi.show(1);
            xiaoxi.find('input.weui_input').focus();
            e.stopPropagation();
        });

    });

    $('body').on('click','.fasong',function(){
        var that = $(this);
        var input = $(this).parents('div.weui_vcode').find('input');
        var content = input.val();
        if(!content){ $.toast("内容不能为空", "forbidden");return false;}
        var pid = Number($(this).parents('div.weui_vcode').find('input').attr('pid'));
        var pin = $(this).parents('div.weui-border-b').find('div.liketext');
        var gid = {:I('get.id')};
        $.ajax({
            url:"{:create_mobile_url("setmessage")}",
            type:"post",
            dataType:"json",
            data:{'content':content,'gid':gid,'pid':pid},
            success:function(data){
                console.log(data);
                if (data.status == 1) {
                    $.toast(data.info);
                    setTimeout(function(){
                        if(pid == 0){
                            var p ='<ul class="weui-comment"> <li class="weui-comment-item" id="' + data.mess.id+
                                    '"> <div class="userinfo"> <strong class="nickname" style="padding-left: 35px;">' + data.mess.nickname+
                                    '</strong> <img class="avatar" src="' + data.mess.headimgurl+
                                    '"> </div> <div class="weui-comment-msg" style="padding-left: 35px;"> <span class="stat">' +content+
                                    '</span></div></li></ul>';
                            $(p).appendTo(pin);
                        }else{
                            var p ='<div class="replay" style="margin-top: 6px" id="'+data.mess.id+'">'+
                                    '<span class="nickname" style="font-size: 15px">'+data.mess.nickname+'</span>&nbsp;回复 '+data.mess.repeNickname+':'+
                                    '<span class="weui-comment-msg">'+content+'</span>'+
                                    '</div>';
                            if($('#'+pid).attr('class') == 'weui-comment-item'){
                                $(p).appendTo($('#'+pid).find('div.weui-comment-msg'));
                            }else{

                                $(p).appendTo($('#'+pid).parents('div.weui-comment-msg'));
                            }
                        }
                        input.val("");
                        input.attr('pid',0);
                        input.attr('placeholder','评论');
                    },1500);
                } else {
                    $.toast(data.info, "forbidden");
                }
            },
            error:function(){
                $.toast("错误", "forbidden");
            }
        });
    });
</script>

</html>